package com.lc.rongzecaifu.fragment;


import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.lc.rongzecaifu.MyApplication;
import com.lc.rongzecaifu.adapter.MyInvestlistAdapter_New;
import com.lc.rongzecaifu.conn.JsonAccessToken;
import com.lc.rongzecaifu.conn.JsonInvest;
import com.lc.rongzecaifu.conn.JsonInvestfilter;
import com.lc.rongzecaifu.rongzecaifu.R;
import com.lc.rongzecaifu.toast.LovelyToast;
import com.lc.rongzecaifu.view.BaseFragment;
import com.lc.rongzecaifu.view.SimpleDividerItemDecoration;
import com.zcx.helper.bound.BoundViewHelper;
import com.zcx.helper.http.AsyCallBack;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import in.srain.cube.views.ptr.PtrClassicDefaultHeader;
import in.srain.cube.views.ptr.PtrFrameLayout;
import in.srain.cube.views.ptr.PtrHandler;
import in.srain.cube.views.ptr.PtrUIHandler;
import in.srain.cube.views.ptr.indicator.PtrIndicator;

/**
 * 动态
 *
 * @author Ansen
 * @create time 2015-09-08
 */
public class DynamicFragment extends BaseFragment implements View.OnClickListener {
    @Bind(R.id.rv_01)
    RecyclerView rv01;

    public static TextView tvSp1;


    @Bind(R.id.iv_sp_1)
    ImageView ivSp1;
    @Bind(R.id.ll_sp_1)
    LinearLayout llSp1;
    @Bind(R.id.tv_sp_2)
    TextView tvSp2;
    @Bind(R.id.iv_sp_2)
    ImageView ivSp2;
    @Bind(R.id.ll_sp_2)
    LinearLayout llSp2;

    public static TextView tvSp3;
    @Bind(R.id.iv_sp_3)
    ImageView ivSp3;
    @Bind(R.id.ll_sp_3)
    LinearLayout llSp3;

  public static   TextView tvSp4;
    @Bind(R.id.iv_sp_4)
    ImageView ivSp4;
    @Bind(R.id.ll_sp_4)
    LinearLayout llSp4;
    @Bind(R.id.store_house_ptr_frame)
    PtrFrameLayout store_house_ptr_frame;
    private PtrClassicDefaultHeader header;
    private int isInvest = 1;//MyInvestlistAdapter.INVESTMODE
    private RecyclerView.Adapter mAdapter;
    private RecyclerView.LayoutManager mLayoutManager;
    private List<String> list0 = new ArrayList<>();
    private List<String> list1 = new ArrayList<>();
    private List<String> list2 = new ArrayList<>();
    private List<String> list3 = new ArrayList<>();
    public List<JsonInvestfilter.Info.ListContent> borrowTypeList;
    //    public List<JsonInvestfilter.Info.ListContent> borrowInterestRateList;
    public List<JsonInvestfilter.Info.ListContent> borrowDurationList;
    public List<JsonInvestfilter.Info.ListContent> borrowStatusList;
    private List<JsonInvest.Info.ListContent> list = new ArrayList<>();

    public static int nowPage = 1;
    public int totalPages = 1;
    public int pageSize = 0;
    public int totalRows = 0;
    public boolean canLoadMore = true;

    /* show_type = "normal";
     nowPage = 1;
     select_id = null;
     qixian_id = "0";
     toubiao_id = "0";*/
    public static String show_type = "normal";
    private TextView tv_invest_list;
    private TextView tv_regular_list;
    private PopupWindow popLeft;
    private View layoutLeft;
    private ListView menulistLeft;
    public static String select_id;


    private String shouyi_id;

    public static String qixian_id;

    public static String toubiao_id;

    private LinearLayout pop_layout;
    ScrollSpeedLinearLayoutManger scrollSpeedLinearLayoutManger;

    public DynamicFragment() {
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
//         View view = BoundViewHelper.boundView(this, MyApplication.scaleScreenHelper.loadView((ViewGroup) inflater.inflate(R.layout.fragment_second, null)));
        View view = BoundViewHelper.boundView(this, MyApplication.scaleScreenHelper.loadView((ViewGroup) inflater.inflate(R.layout.fragment_second, null)));

        ButterKnife.bind(this, view);
        tvSp1 = (TextView) view.findViewById(R.id.tv_sp_1);
        tvSp3 = (TextView) view.findViewById(R.id.tv_sp_3);

        tvSp4 = (TextView) view.findViewById(R.id.tv_sp_4);
        tv_invest_list = (TextView) view.findViewById(R.id.tv_invest_list);
        tv_regular_list = (TextView) view.findViewById(R.id.tv_regular_list);
        pop_layout = (LinearLayout) view.findViewById(R.id.pop_layout);
        initView();
        initListener();
        initRefreshListener();
        return view;
    }


    @Override
    public void onResume() {
        super.onResume();
        Log.d("zoumeizou生命周期", "3333333333333333333333333");

        if (list0.isEmpty()) {
            getTypeAccessToken();
        } else {
        //    list.clear();
            nowPage = 1;
            initData(false, nowPage);
        }
    }

    private void getTypeAccessToken() {
        new JsonAccessToken("index/invest_filter", new AsyCallBack<JsonAccessToken.Info>() {
            @Override
            public void onSuccess(String toast, int type, JsonAccessToken.Info info) throws Exception {
                if (info != null) {
                    if (!TextUtils.isEmpty(info.access_token)) {
                        initTypeData(info.access_token);
                    } else {

                        LovelyToast.makeText(getActivity(), "安全验证失败！", 0, LovelyToast
                                .SUCCESS, LovelyToast.SCALE);
                    }
                }
            }

            @Override
            public void onFail(String toast, int type) throws Exception {
                super.onFail(toast, type);
                LovelyToast.makeText(getActivity(), "安全验证失败", 0, LovelyToast
                        .SUCCESS, LovelyToast.SCALE);
            }
        }).execute(getActivity(), false);
    }

    private void getInvestDataAccessToken(final boolean b, final int page) {
        new JsonAccessToken("index/invest", new AsyCallBack<JsonAccessToken.Info>() {
            @Override
            public void onSuccess(String toast, int type, JsonAccessToken.Info info) throws Exception {
           /*     if (info != null) {
                    if (!TextUtils.isEmpty(info.access_token)) {
                        initInvestData(info.access_token, b, page);
                    } else {
                        canLoadMore = true;
                        LovelyToast.makeText(getActivity(), "安全验证失败", 0, LovelyToast
                                .SUCCESS, LovelyToast.SCALE);
                    }

                }*/
                if (info != null) {
                    if (!TextUtils.isEmpty(info.access_token)) {
                        initInvestData(info.access_token, b, page);
                    } else {
                        //UtilToast.show(NewsActivity.this, "安全验证失败！");
                        LovelyToast.makeText(getActivity(), "安全验证失败~", 0, LovelyToast
                                .SUCCESS, LovelyToast.SCALE);
                        canLoadMore = true;
                        if (!b) {
                            store_house_ptr_frame.refreshComplete();
                        }
                    }

                }

            }

            @Override
            public void onFail(String toast, int type) throws Exception {
                super.onFail(toast, type);
                canLoadMore = true;
                LovelyToast.makeText(getActivity(), "安全验证失败", 0, LovelyToast
                        .SUCCESS, LovelyToast.SCALE);
            }
        }).execute(getActivity(), false);
    }

    @Override
    public void onHiddenChanged(boolean hidden) {
        super.onHiddenChanged(hidden);
        Log.d("111111111", "特么的周期啊");
//        new JsonInvest(access_token, show_type, String.valueOf(page), select_id, qixian_id, toubiao_id, new AsyCallBack<JsonInvest.Info>() {
        show_type = "normal";
        nowPage = 1;
      /*  select_id = "0";
        qixian_id = null;
        toubiao_id = "0";*/

        select_id = "0";
        toubiao_id = "0";
        qixian_id = "null";
        initData(false, nowPage);
    }



    private void initTypeData(String access_token) {
        new JsonInvestfilter(access_token, new AsyCallBack<JsonInvestfilter.Info>() {
            @Override
            public void onStart(int type) throws Exception {
                super.onStart(type);
                //  showLoading();


            }

            @Override
            public void onSuccess(String toast, int type, JsonInvestfilter.Info info) throws Exception {
                if (info != null) {
                    borrowTypeList = info.borrow_type;
                    //borrowInterestRateList = info.borrowInterestRateList;
                    borrowDurationList = info.borrow_duration;
                    borrowStatusList = info.borrow_status;
                    for (int i = 0; i < borrowTypeList.size(); i++) {
                        list0.add(borrowTypeList.get(i).name);
                    }
                /*    for (int i = 0; i < borrowInterestRateList.size(); i++) {
                        list1.add(borrowInterestRateList.get(i).name);
                    }*/
                    for (int i = 0; i < borrowDurationList.size(); i++) {
                        list2.add(borrowDurationList.get(i).name);
                    }
                    for (int i = 0; i < borrowStatusList.size(); i++) {
                        list3.add(borrowStatusList.get(i).name);
                    }

                    select_id = borrowTypeList.get(0).id;
                    toubiao_id = borrowStatusList.get(0).id;

                    nowPage = 1;
                    initData(false, nowPage);
                } else {

                 /*   LovelyToast.makeText(getActivity(), JsonInvestfilter.TOAST, 0, LovelyToast
                            .SUCCESS, LovelyToast.SCALE);*/
                    LovelyToast.makeText(getActivity(), "安全验证失败", 0, LovelyToast
                            .SUCCESS, LovelyToast.SCALE);
                }
            }

            @Override
            public void onEnd(String toast, int type) throws Exception {
                //   dismissLoading();
                mAdapter.notifyDataSetChanged();
            }

        }).execute(getActivity(), false);

    }

    private void initView() {

        tvSp1.setText("类型");
        tvSp2.setText("收益");
        tvSp3.setText("期限");
        tvSp4.setText("状态");
        rv01.setHasFixedSize(true);


        mLayoutManager = new LinearLayoutManager(getActivity());

        scrollSpeedLinearLayoutManger = new ScrollSpeedLinearLayoutManger(getContext());
        //rv01.setLayoutManager(scrollSpeedLinearLayoutManger);
        rv01.setLayoutManager(mLayoutManager);
        mAdapter = new MyInvestlistAdapter_New(getActivity(), list, isInvest);
        Drawable drawable = ContextCompat.getDrawable(getActivity(), R.drawable.line_divider);
        rv01.addItemDecoration(new SimpleDividerItemDecoration(getActivity(), drawable, 2));
        rv01.setAdapter(mAdapter);
        header = new PtrClassicDefaultHeader(getActivity());
        store_house_ptr_frame.setHeaderView(header);
      /*  if (list0.isEmpty()) {
            getTypeAccessToken();
        } else {
            list.clear();
            nowPage = 1;
            initData(false, nowPage);
        }*/
    }

    private void initListener() {
        ivSp1.setOnClickListener(this);
        ivSp2.setOnClickListener(this);
        ivSp3.setOnClickListener(this);
        ivSp4.setOnClickListener(this);
        llSp1.setOnClickListener(this);
        llSp2.setOnClickListener(this);
        llSp3.setOnClickListener(this);
        llSp4.setOnClickListener(this);

    }


    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.tv_sp_1:
            case R.id.iv_sp_1:
                break;
            case R.id.ll_sp_1:
                if (list0.isEmpty()) {
                    getTypeAccessToken();
                } else {
                    if (popLeft != null && popLeft.isShowing()) {
                        popLeft.dismiss();
                    } else {
                        layoutLeft = getActivity().getLayoutInflater().inflate(
                                R.layout.pop_menulist, null);
                        menulistLeft = (ListView) layoutLeft
                                .findViewById(R.id.menulist);
                        menulistLeft.setAdapter(new ArrayAdapter<String>(getActivity(), R.layout.spinner_list_item, list0));

                        menulistLeft.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                            @Override
                            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

                                tvSp1.setText(list0.get(position));


                                select_id = borrowTypeList.get(position).id;
                                // popupWindow.dismiss();
                                list.clear();
                                nowPage = 1;
                                initData(true, nowPage);
                                popLeft.dismiss();
                            }
                        });
                        popLeft = new PopupWindow(layoutLeft, pop_layout.getWidth(),
                                RelativeLayout.LayoutParams.WRAP_CONTENT);
                      /*  ColorDrawable cd = new ColorDrawable(getResources().getColor(R.color.colorWhite));
//
                        popLeft.setBackgroundDrawable(cd);*/
                        popLeft.setAnimationStyle(R.style.PopupAnimation);
                        popLeft.update();
                        popLeft.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
                        popLeft.setTouchable(true); // 设置popupwindow可点击
                        popLeft.setOutsideTouchable(true); // 设置popupwindow外部可点击
                        popLeft.setFocusable(true); // 获取焦点

                        popLeft.showAsDropDown(pop_layout, 0, 0);
                        popLeft.setTouchInterceptor(new View.OnTouchListener() {

                            @Override
                            public boolean onTouch(View v, MotionEvent event) {
                                // 如果点击了popupwindow的外部，popupwindow也会消失
                                if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
                                    popLeft.dismiss();
                                    return true;
                                }
                                return false;
                            }
                        });

                    }

                }

                break;

            case R.id.tv_sp_2:
            case R.id.iv_sp_2:
                break;
            case R.id.ll_sp_2:
                if (list0.isEmpty()) {
                    getTypeAccessToken();
                } else {

                    if (popLeft != null && popLeft.isShowing()) {
                        popLeft.dismiss();
                    } else {
                        layoutLeft = getActivity().getLayoutInflater().inflate(
                                R.layout.pop_menulist, null);
                        menulistLeft = (ListView) layoutLeft
                                .findViewById(R.id.menulist);
                        menulistLeft.setAdapter(new ArrayAdapter<String>(getActivity(), R.layout.spinner_list_item, list1));

                        menulistLeft.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                            @Override
                            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                                tvSp2.setText(list1.get(position));
                                // shouyi_id = borrowInterestRateList.get(position).id;
                                list.clear();
                                nowPage = 1;
                                initData(true, nowPage);
                                mAdapter.notifyDataSetChanged();
                                popLeft.dismiss();

                            }
                        });
                        popLeft = new PopupWindow(layoutLeft, pop_layout.getWidth(),
                                RelativeLayout.LayoutParams.WRAP_CONTENT);
                        ColorDrawable cd = new ColorDrawable(getResources().getColor(R.color.colorWhite));
                        popLeft.setBackgroundDrawable(cd);
                        popLeft.setAnimationStyle(R.style.PopupAnimation);
                        popLeft.update();
                        popLeft.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
                        popLeft.setTouchable(true); // 设置popupwindow可点击
                        popLeft.setOutsideTouchable(true); // 设置popupwindow外部可点击
                        popLeft.setFocusable(true); // 获取焦点

                        popLeft.showAsDropDown(pop_layout, 0, 0);
                        popLeft.setTouchInterceptor(new View.OnTouchListener() {

                            @Override
                            public boolean onTouch(View v, MotionEvent event) {
                                // 如果点击了popupwindow的外部，popupwindow也会消失
                                if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
                                    popLeft.dismiss();
                                    return true;
                                }
                                return false;
                            }
                        });

                    }
                }

                break;

            case R.id.tv_sp_3:
            case R.id.iv_sp_3:
                break;
            case R.id.ll_sp_3:
                if (list0.isEmpty()) {
                    getTypeAccessToken();
                } else {
                    if (popLeft != null && popLeft.isShowing()) {
                        popLeft.dismiss();
                    } else {
                        layoutLeft = getActivity().getLayoutInflater().inflate(
                                R.layout.pop_menulist, null);
                        menulistLeft = (ListView) layoutLeft
                                .findViewById(R.id.menulist);
                        menulistLeft.setAdapter(new ArrayAdapter<String>(getActivity(), R.layout.spinner_list_item, list2));

                        menulistLeft.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                            @Override
                            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                                tvSp3.setText(list2.get(position));

                                qixian_id = borrowDurationList.get(position).id;

                                // popupWindow.dismiss();

                                list.clear();
                                mAdapter.notifyDataSetChanged();
                                initData(true, nowPage);
                                popLeft.dismiss();
                            }
                        });
                        popLeft = new PopupWindow(layoutLeft, pop_layout.getWidth(),
                                RelativeLayout.LayoutParams.WRAP_CONTENT);
                      /*  ColorDrawable cd = new ColorDrawable(getResources().getColor(R.color.colorWhite));
                        popLeft.setBackgroundDrawable(cd);*/
                        popLeft.setAnimationStyle(R.style.PopupAnimation);
                        popLeft.update();
                        popLeft.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
                        popLeft.setTouchable(true); // 设置popupwindow可点击
                        popLeft.setOutsideTouchable(true); // 设置popupwindow外部可点击
                        popLeft.setFocusable(true); // 获取焦点
                        popLeft.showAsDropDown(pop_layout, 0, 0);
                        popLeft.setTouchInterceptor(new View.OnTouchListener() {

                            @Override
                            public boolean onTouch(View v, MotionEvent event) {
                                // 如果点击了popupwindow的外部，popupwindow也会消失
                                if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
                                    popLeft.dismiss();
                                    return true;
                                }
                                return false;
                            }
                        });

                    }


                }
                break;
            case R.id.tv_sp_4:
            case R.id.iv_sp_4:
                break;
            case R.id.ll_sp_4:
                if (list0.isEmpty()) {
                    getTypeAccessToken();
                } else {
                    if (popLeft != null && popLeft.isShowing()) {
                        popLeft.dismiss();
                    } else {
                        layoutLeft = getActivity().getLayoutInflater().inflate(
                                R.layout.pop_menulist, null);
                        menulistLeft = (ListView) layoutLeft
                                .findViewById(R.id.menulist);
                        menulistLeft.setAdapter(new ArrayAdapter<String>(getActivity(), R.layout.spinner_list_item, list3));
                        menulistLeft.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                            @Override
                            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                                tvSp4.setText(list3.get(position));
                                toubiao_id = borrowStatusList.get(position).id;
                                list.clear();
                                nowPage = 1;
                                initData(true, nowPage);
                                popLeft.dismiss();
                            }
                        });
                        popLeft = new PopupWindow(layoutLeft, pop_layout.getWidth(),
                                RelativeLayout.LayoutParams.WRAP_CONTENT);
                    /*    ColorDrawable cd = new ColorDrawable(getResources().getColor(R.color.colorWhite));
                        popLeft.setBackgroundDrawable(cd);*/
                        popLeft.setAnimationStyle(R.style.PopupAnimation);
                        popLeft.update();
                        popLeft.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
                        popLeft.setTouchable(true); // 设置popupwindow可点击
                        popLeft.setOutsideTouchable(true); // 设置popupwindow外部可点击
                        popLeft.setFocusable(true); // 获取焦点

                        popLeft.showAsDropDown(pop_layout, 0, 0);
                        popLeft.setTouchInterceptor(new View.OnTouchListener() {

                            @Override
                            public boolean onTouch(View v, MotionEvent event) {
                                // 如果点击了popupwindow的外部，popupwindow也会消失
                                if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
                                    popLeft.dismiss();
                                    return true;
                                }
                                return false;
                            }
                        });
                    }
                }
                break;
        }
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        ButterKnife.unbind(this);
    }

    private void initRefreshListener() {
        rv01.setOnScrollListener(new RecyclerView.OnScrollListener() {
            @Override
            public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
                super.onScrolled(recyclerView, dx, dy);
                int lastVisibleItemPosition = ((LinearLayoutManager) mLayoutManager).findLastVisibleItemPosition();
                if (dy > 0 && lastVisibleItemPosition + 1 == mAdapter.getItemCount() && canLoadMore) {
               /*     rv01.setOnTouchListener(
                            new View.OnTouchListener() {
                                @Override
                                public boolean onTouch(View v, MotionEvent event) {
                                    if (true) {
                                        return true;
                                    } else {
                                        return false;
                                    }
                                }
                            }
                    );
*/
                    canLoadMore = false;
                    rv01.setEnabled(false);
                    if (nowPage < totalPages) {
                        initData(true, nowPage + 1);
                    } else {

                        LovelyToast.makeText(getActivity(), "没有更多了~", 0, LovelyToast
                                .SUCCESS, LovelyToast.SCALE);
                    }
                }
            }
        });

        store_house_ptr_frame.setPtrHandler(new PtrHandler() {
            @Override
            public boolean checkCanDoRefresh(PtrFrameLayout frame, View content, View header) {
                int firstVisibleItemPosition = ((LinearLayoutManager) mLayoutManager).findFirstCompletelyVisibleItemPosition();
                return (firstVisibleItemPosition == 0 || list.size() == 0) && list0.size() != 0;
            }

            @Override
            public void onRefreshBegin(PtrFrameLayout frame) {
            list.clear();
                nowPage = 1;
                initData(false, nowPage);
            }
        });
        store_house_ptr_frame.addPtrUIHandler(new PtrUIHandler() {
            @Override
            public void onUIReset(PtrFrameLayout frame) {
                header.onUIReset(frame);
            }

            @Override
            public void onUIRefreshPrepare(PtrFrameLayout frame) {
                header.onUIRefreshPrepare(frame);
            }

            @Override
            public void onUIRefreshBegin(PtrFrameLayout frame) {
                header.onUIRefreshBegin(frame);
            }

            @Override
            public void onUIRefreshComplete(PtrFrameLayout frame) {
                header.onUIRefreshComplete(frame);
            }

            @Override
            public void onUIPositionChange(PtrFrameLayout frame, boolean isUnderTouch, byte status, PtrIndicator ptrIndicator) {
                header.onUIPositionChange(frame, isUnderTouch, status, ptrIndicator);
            }
        });
    }

    private void initData(boolean b, final int page) {
        getInvestDataAccessToken(b, page);
    }


    private void initInvestData(String access_token, final boolean isShow, final int page) {

        // new JsonInvest(access_token, show_type, String.valueOf(page), borrowTypeList.get(sp01.getSelectedItemPosition()).id, borrowInterestRateList.get(sp02.getSelectedItemPosition()).id, borrowDurationList.get(sp03.getSelectedItemPosition()).id, borrowStatusList.get(sp04.getSelectedItemPosition()).id, new AsyCallBack<JsonInvest.Info>() {
        new JsonInvest(access_token, show_type, String.valueOf(page), select_id, qixian_id, toubiao_id, new AsyCallBack<JsonInvest.Info>() {

            @Override
            public void onStart(int type) throws Exception {
                super.onStart(type);
                showLoading();
            }

            @Override
            public void onSuccess(String toast, int type, JsonInvest.Info info) throws Exception {
                if (info != null) {
                  //  list.clear();
                    list.addAll(info.list);
                    nowPage = info.page.nowPage;
                    totalPages = info.page.totalPages;
                    pageSize = info.page.pageSize;
                    totalRows = info.page.totalRows;
//                    if (list.isEmpty()) {
//                        UtilToast.show(getActivity(), "无相关记录！");
//                    }
                }
            }

            @Override
            public void onFail(String toast, int type) throws Exception {
                super.onFail(toast, type);
                LovelyToast.makeText(getActivity(), "安全验证失败", 0, LovelyToast
                        .SUCCESS, LovelyToast.SCALE);
                dismissLoading();
            }

            @Override
            public void onEnd(String toast, int type) throws Exception {
                dismissLoading();
                if (!isShow) {
                    store_house_ptr_frame.refreshComplete();
                }
                canLoadMore = true;
                mAdapter.notifyDataSetChanged();
            }

        }).execute(getActivity(), isShow);
    }


}
